package org.ntu.rtsearch.search.model;

public class Accumulator {
	
	private long normFactor;
	
	private double score;
	
	public Accumulator(long normFactor, double score) {
		this.normFactor = normFactor;
		this.score = score;
	}
	
	public synchronized Accumulator addScore(double add) {
		score += add;
		return this;
	}

	public synchronized Accumulator addNormFactor(long add) {
		normFactor += add * add;
		return this;
	}

	public float getScore() {
		return (float) (score / Math.sqrt(normFactor));
	}

	
}
